package com.dc.business.datacollectbusiness.controller;

import com.dc.business.datacollectbusiness.model.HSminiProgramResult;
import com.dc.business.datacollectbusiness.model.Result;
import com.dc.business.datacollectbusiness.service.HSminiProgramService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;


@RestController
@CrossOrigin
@RequestMapping("/api/HsMiniProgram")
public class HSminiProgramController {

    @Autowired
    private HSminiProgramService hsminiProgramService;


    @GetMapping("/dataSelect")
    public Result dataSelect(@RequestParam(value = "startDate", required = true) String startDate,
                             @RequestParam(value = "endDate", required = true) String endDate,
                             @RequestParam(value = "collegeAndPoint", required = true) String collegeAndPoint) {
        List<HSminiProgramResult> hSminiProgramResults = hsminiProgramService.dataSelect(startDate, endDate, collegeAndPoint);
        return Result.success(hSminiProgramResults);
    }

    @GetMapping("/dataBarChart")
    public Result dataBarChart(@RequestParam(value = "collegeName", required = true) String collegeName,
                               @RequestParam(value = "timeRange", required = true) String timeRange) {
        List<HashMap<String, String>> hashMaps = hsminiProgramService.dataBarChart(collegeName, timeRange);
        return Result.success(hashMaps);
    }

    @GetMapping("/getAllWaterorElec")
    public Result getAllWaterorElec(@RequestParam(value = "timeRange", required = true) String timeRange) {
        return Result.success(hsminiProgramService.getAllWaterorElec(timeRange));
    }

}
